package com.example.oop;

/**
 * 员工类 - 继承Person类
 * 对比C#的继承语法
 */
public class Employee extends Person {
    // 私有字段
    private String employeeId;
    private double salary;
    private String department;
    
    // 构造函数
    public Employee(String name, int age, String employeeId, double salary) {
        super(name, age); // 调用父类构造函数 (类似C#的base())
        this.employeeId = employeeId;
        this.salary = salary;
    }
    
    public Employee(String name, int age, String email, String employeeId, 
                   double salary, String department) {
        super(name, age, email); // 调用父类构造函数
        this.employeeId = employeeId;
        this.salary = salary;
        this.department = department;
    }
    
    // Getter和Setter方法
    public String getEmployeeId() {
        return employeeId;
    }
    
    public void setEmployeeId(String employeeId) {
        this.employeeId = employeeId;
    }
    
    public double getSalary() {
        return salary;
    }
    
    public void setSalary(double salary) {
        if (salary >= 0) {
            this.salary = salary;
        }
    }
    
    public String getDepartment() {
        return department;
    }
    
    public void setDepartment(String department) {
        this.department = department;
    }
    
    // 重写父类方法 (类似C#的override)
    @Override
    public void introduce() {
        super.introduce(); // 调用父类方法 (类似C#的base.方法名())
        System.out.println("员工ID: " + employeeId);
        System.out.println("部门: " + department);
        System.out.println("薪资: " + salary);
    }
    
    // 新增方法
    public void work() {
        System.out.println(getName() + " 正在工作...");
    }
    
    public void takeBreak() {
        System.out.println(getName() + " 正在休息...");
    }
    
    // 重写toString方法
    @Override
    public String toString() {
        return "Employee{" +
                "name='" + getName() + '\'' +
                ", age=" + getAge() +
                ", email='" + getEmail() + '\'' +
                ", employeeId='" + employeeId + '\'' +
                ", salary=" + salary +
                ", department='" + department + '\'' +
                '}';
    }
} 